/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.DeliveryRecipients;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface DeliveryRecipientsMapper {
    /* @mbggenerated */
    @Delete({
        "delete from delivery_recipients",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into delivery_recipients (user_id, recipients_name, ",
        "recipients_telephone, province, ",
        "city, district, ",
        "recipients_address, create_time, ",
        "state)",
        "values (#{userId,jdbcType=INTEGER}, #{recipientsName,jdbcType=VARCHAR}, ",
        "#{recipientsTelephone,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, ",
        "#{city,jdbcType=VARCHAR}, #{district,jdbcType=VARCHAR}, ",
        "#{recipientsAddress,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{state,jdbcType=INTEGER})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(DeliveryRecipients record);

    /* @mbggenerated */
    @InsertProvider(type=DeliveryRecipientsSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(DeliveryRecipients record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, user_id, recipients_name, recipients_telephone, province, city, district, ",
        "recipients_address, create_time, state",
        "from delivery_recipients",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_name", property="recipientsName", jdbcType=JdbcType.VARCHAR),
        @Result(column="recipients_telephone", property="recipientsTelephone", jdbcType=JdbcType.VARCHAR),
        @Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="district", property="district", jdbcType=JdbcType.VARCHAR),
        @Result(column="recipients_address", property="recipientsAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER)
    })
    DeliveryRecipients selectByPrimaryKey(Integer id);

    /* @mbggenerated */
    @UpdateProvider(type=DeliveryRecipientsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DeliveryRecipients record);

    /* @mbggenerated */
    @Update({
        "update delivery_recipients",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "recipients_name = #{recipientsName,jdbcType=VARCHAR},",
          "recipients_telephone = #{recipientsTelephone,jdbcType=VARCHAR},",
          "province = #{province,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "district = #{district,jdbcType=VARCHAR},",
          "recipients_address = #{recipientsAddress,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "state = #{state,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DeliveryRecipients record);
    
    /* @mbggenerated */
    @Select({
        "select",
        "id, user_id, recipients_name, recipients_telephone, province, city, district, ",
        "recipients_address, create_time, state",
        "from delivery_recipients",
        "where user_id = #{userId,jdbcType=INTEGER} and state = 1"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="recipients_name", property="recipientsName", jdbcType=JdbcType.VARCHAR),
        @Result(column="recipients_telephone", property="recipientsTelephone", jdbcType=JdbcType.VARCHAR),
        @Result(column="province", property="province", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="district", property="district", jdbcType=JdbcType.VARCHAR),
        @Result(column="recipients_address", property="recipientsAddress", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="state", property="state", jdbcType=JdbcType.INTEGER)
    })
    List<DeliveryRecipients> selectByUserId(Integer userId);
}